package com.example.administrator.zkdemo.activity;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.v4.app.FragmentActivity;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;

import com.orhanobut.logger.Logger;
import com.zkteco.android.utils.ZKActivityCollector;

import butterknife.ButterKnife;

public class ZKBaseActivity extends FragmentActivity {
    protected Context mContext;

    private void init() {
        Logger.d(getClass().getSimpleName());
        ZKActivityCollector.addActivity(this);
        this.mContext = getApplicationContext();
    }

    public void hideSoftKeyboard(View paramView) {
        paramView.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View paramView, MotionEvent paramMotionEvent) {
                if (ZKBaseActivity.this.getCurrentFocus() != null)
                    return ((InputMethodManager) ZKBaseActivity.this.getSystemService("input_method")).hideSoftInputFromWindow(ZKBaseActivity.this.getCurrentFocus().getWindowToken(), 0);
                return false;
            }
        });
    }

    public void initLayout(@LayoutRes int paramInt) {
        setContentView(paramInt);
        ButterKnife.bind(this);
    }

    protected void onCreate(Bundle paramBundle) {
        super.onCreate(paramBundle);
        init();
    }

    protected void onDestroy() {
        super.onDestroy();
        ZKActivityCollector.removeActivity(this);
    }
}
